package com.llianejapan.ImeDo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.ClipboardManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.llianejapan.*;
import com.llianejapan.RomaTo.RomaToHK;
import com.llianejapan.RomaTo.RomaToKanji;

public class ImeWV extends Activity{
	public Button wvhira;
	public Button wvkata;
	public Button wvkanji;
	public Button wvok;
	@Override	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (getCurrentFocus() != null)
		  Log.e("LDEBUG",getCurrentFocus().getContext().toString());
		else
			Log.e("LDEBUG", "EMPTY");
		setTheme(android.R.style.Theme_Translucent);
		setContentView(R.layout.ime_wv);
		wvhira = (Button) findViewById(R.id.wvhira);
		wvkata = (Button) findViewById(R.id.wvkata);
		wvkanji = (Button) findViewById(R.id.wvkanji);
		LlianeGlobal.wv1 = (EditText) findViewById(R.id.wv1);
		LlianeGlobal.wv2 = (EditText) findViewById(R.id.wv2);
		wvok = (Button) findViewById(R.id.wvok);
		if (LlianeGlobal.wvto != null)
			  LlianeGlobal.wv2.setText(LlianeGlobal.wvto.getText());
		wvhira.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v){
				LlianeGlobal.radio_hira.setChecked(true);
				LlianeGlobal.wv2.append(RomaToHK.roma2hk(LlianeGlobal.wv1.getText()));
				LlianeGlobal.wv1.setText("");
			}
		});
		wvkata.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v){
				LlianeGlobal.radio_kata.setChecked(true);
				LlianeGlobal.wv2.append(RomaToHK.roma2hk(LlianeGlobal.wv1.getText()));
				LlianeGlobal.wv1.setText("");
			}
		});
		wvkanji.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v){
				LlianeGlobal.stringBuffer = LlianeGlobal.wv1.getText().toString();
				Intent intent = new Intent();    		
				intent.setClass(ImeWV.this, RomaToKanji.class);
				RomaToKanji.forTranslate = 2;
				startActivity(intent);				
			}
		});
		wvok.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v)
			{
				ClipboardManager cb = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
				cb.setText(LlianeGlobal.wv2.getText());
				if (LlianeGlobal.wvto != null)
				  LlianeGlobal.wvto.setText(LlianeGlobal.wv2.getText());
				finish();
			}
		});
		
	}
}
